# Copyright (c) OpenMMLab. All rights reserved.
# <---jittor import--->
import jittor as jt
import numpy as np
jt.flags.use_cuda = 1


def clip_sigmoid(x, eps=1e-4):
    """Sigmoid function for input feature.

    Args:
        x (jt.Var): Input feature map with the shape of [B, N, H, W].
        eps (float, optional): Lower bound of the range to be clamped to.
            Defaults to 1e-4.

    Returns:
        jt.Var: Feature map after sigmoid.
    """
    x = jt.array(x)
    y = jt.clamp(x.sigmoid_(), min_v=eps, max_v=1 - eps)
    return y
